// Quentin Gallea, and Dominic Rohner
// Globalization Mitigates the Risk of Conflict Caused by Strategic Territory
// Forthcoming in Proceedings of the National Academy of Sciences, 2021

// Replication file (STATA)

// Install packages
// ssc install estout, replace
// ssc install reghdfe, replace
// ssc install ftools, replace
// ssc install coefplot, replace
// ssc install binscatter, replace
// ssc install spmap,replace
// ssc install acreg, replace


clear
clear mata
clear matrix
set more off, perm
set mem 1000m 
set matsize 1000

global path="C:\Users\quent\Dropbox\PhD\Strait\DoFile"
cd "C:\Users\quent\Dropbox\PhD\Strait\DoFile"

// Open data
use "$path/globalization.dta"

/************************************ A. Main Article ************************************/

/**************************************** Tables *****************************************/

* Table 1. Regression analysis of the impact of maritime choke point proximity on violent conflict events
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist   if year>=1989 , absorb(year xcoord) cluster(gid)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_y Year FE") 

* Table 2.  Regression analysis of the impact of maritime choke point proximity and world trade openness on violent events
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist trade_lin  if year>=1989 , absorb(year xcoord gadm0_id) cluster(gid)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") /// 
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE"  "FE_y Year FE") 

/**************************************** Figures *****************************************/

* Create the points for the maps 
	preserve
	collapse (sum) conflict (first) col row near_dist xcoord ycoord, by(gid)
	keep if conflict>0 & conflict!=.
	save "$path\conflict.dta" ,replace
	restore
	preserve
	sum tradew,d
	keep if tradew>=r(p50)
	collapse (sum) conflict (first) col row  near_dist near_dist_q* xcoord ycoord, by(gid)
	gen quartile=(near_dist_q1==1)
	replace quartile=2 if near_dist_q2==1
	replace quartile=3 if near_dist_q3==1
	replace quartile=4 if near_dist_q4==1
	
	keep if conflict>0 & conflict!=.
	save "$path\conflict_hightrade.dta" ,replace
	use  "$path\conflict_hightrade.dta",clear
	keep if  row<200 & row>107 & col<444 & col>323 
	save "$path\map1.dta" ,replace
	use  "$path\conflict_hightrade.dta",clear
	keep if col>117 & col<250 & row<225 & row>166
	save "$path\map3.dta" ,replace
	restore
	preserve
	sum tradew,d
	keep if tradew<r(p50)
	collapse (sum) conflict (first) col row near_dist near_dist_q* xcoord ycoord, by(gid)
	gen quartile=(near_dist_q1==1)
	replace quartile=2 if near_dist_q2==1
	replace quartile=3 if near_dist_q3==1
	replace quartile=4 if near_dist_q4==1
	keep if conflict>0 & conflict!=.
	save "$path\conflict_lowtrade.dta" ,replace
	use  "$path\conflict_lowtrade.dta",clear
	keep if  row<200 & row>107 & col<444 & col>323 
	save "$path\map2.dta" ,replace
	use  "$path\\conflict_lowtrade.dta",clear
	keep if col>117 & col<250 & row<225 & row>166
	save "$path\map4.dta" ,replace
	restore
	
*Figure 2
preserve
collapse (sum) conflict conf_* best (first) col row near_dist* id2 , by(gid)

graph drop _all
spmap near_dist using  "$path\coordprio.dta" if row<200 & row>107 & col<444 & col>323, ///
id(id2) fcolor(Blues) clmethod(custom) clbreaks(-5  -2.359637  -1.604164  -.8368567   0) ocolor( grey%50 grey%50 grey%50 grey%50) /// 
osize(vvvthin vvvthin vvvthin vvvthin)  legend(on)   legtitle("Proximity:") legend(label(2 "1st quartile") ///
label(3 "1st quartile to median" ) label(4 "median to 3rd quartile" ) label(5 "above 3rd quartile" )   ///
size(small))  mosize(vvvthin) mocolor(grey%50) ndsize(none)   ///
name(g0) point(data("$path\map1.dta") legenda(on) /// 
legshow(30) leglabel("Number of conflict") x(xcoord) y(ycoord) size(tiny) fcolor(maroon%30) prange(0.1 0.5) prop(conflict) ocolor(maroon%30) ) ///
title(A. High trade openness (Africa))

spmap near_dist using  "$path\coordprio.dta" if row<200 & row>107 & col<444 & col>323, ///
id(id2) fcolor(Blues) clmethod(custom) clbreaks(-5  -2.359637  -1.604164  -.8368567   0) ocolor(grey%50 grey%50 grey%50 grey%50) /// 
osize(vvvthin vvvthin vvvthin vvvthin)  legend(off) mosize(none) ndsize(none)   ///
point(data("$path\map2.dta") x(xcoord) y(ycoord) size(tiny)  /// 
fcolor(maroon%30) ocolor(maroon%30) prange(0.1 0.5)  prop(conflict)) name(g2) ///
title(B. Low trade openness (Africa))

spmap near_dist using  "$path\coordprio.dta" if col>117 & col<250 & row<225 & row>166, ///
id(id2) fcolor(Blues) clmethod(custom) clbreaks(-5  -2.359637  -1.604164  -.8368567   0) ocolor(grey%50 grey%50 grey%50 grey%50) /// 
osize(vvvthin vvvthin vvvthin vvvthin)  legend(off)    mosize(none) ndsize(none) ///
name(g3) point(data("$path\map3.dta")  /// 
x(xcoord) y(ycoord) size(tiny) fcolor(maroon%30) prange(0.1 0.5) prop(conflict) ocolor(maroon%30) ) ///
title(C. High trade openness (Central Am.))

spmap near_dist using "$path\coordprio.dta" if col>117 & col<250 & row<225 & row>166, ///
id(id2) fcolor(Blues) clmethod(custom) clbreaks(-5  -2.359637  -1.604164  -.8368567   0) ocolor(grey%50 grey%50 grey%50 grey%50) /// 
osize(vvvthin vvvthin vvvthin vvvthin) legend(off)  mosize(none) ndsize(none)   ///
point(data("$path\map4.dta") x(xcoord) y(ycoord) size(tiny)  /// 
fcolor(maroon%30) ocolor(maroon%30) leglabel("Number of conflict") prange(0.1 0.5)  prop(conflict)) name(g4) ///
title(D. Low trade openness (Central Am.))
 
graph combine g0 g2 g3 g4, row(2) graphregion(color(white)) 
restore

*Figure 3
graph drop _all
	foreach v of varlist conflict conf_type1 conf_type2 conf_type3 lnbest{
	qui: reghdfe `v' near_dist  c.tradew#c.near_dist , absorb(year xcoord gadm0_id) cluster(gid)
	margins, dydx(near_dist)  at(tradew= (0.35(0.05)0.6))  saving(marginsfile1, replace) level(90)
	margins, dydx(near_dist)  at(tradew= (0.35(0.05)0.6))  saving(marginsfile2, replace) level(99)
	local max= round(el(r(table),6,1),0.01)
	local min= round(el(r(table),5,11),0.01)
	local jump= round((`max'-`min')/5,0.01)
	
	if ("`v'"=="lnbest"){
		local yaxis=" ylabel(-0.02(0.01)0.02) yscale(range(-0.02 0.02))"
		}
		else{
		local yaxis=" ylabel(-0.004(0.002)0.006) yscale(range(-0.004 0.006))"
		}
	
	combomarginsplot marginsfile1 marginsfile2, fileci1opts(recast(rarea) lwidth(none) fcolor(`color'%50) ///
		yline(0)) fileci2opts(recast(rarea) lwidth(none) fcolor(navy%30) )  ///
		file1opts(recast(line) legend(off) fcolor("navy")) file2opts(recast(line) lwidth(none) fcolor("navy"))  /// 
		graphregion(color(white)) ytitle("") xtitle("World Trade Openness") title("`: variable label `v''") name(`v') ///
		`yaxis'
	}
	graph combine conflict conf_type1 conf_type2 conf_type3 lnbest , row(2) graphregion(color(white))
	
/************************************ B. Supplementary Information ************************************/

* Table S2
sum near_dist,d
gen near_above_med=( near_dist>  -1.604203 )
qui: reghdfe conflict near_dist  trade_lin if year>=1989 , absorb(year xcoord gadm0_id ) cluster(gid)
replace near_above_med=. if near_dist==. & e(sample)!=1
ttest conflict, by(near_above_med)
ttest conf_type1 , by(near_above_med)
ttest conf_type2, by(near_above_med)
ttest conf_type3, by(near_above_med)
ttest best , by(near_above_med)
ttest lnbest , by(near_above_med)

* Figure S2-S5
preserve
collapse (sum) conflict conf_*, by(id2)
spmap conflict using "$path\coordprio.dta" , id(id2) fcolor(Reds) clmethod(custom) clbreaks(-1 0 10 20 30) ocolor(none ..)  osize(none)  legtitle("Number of years")  mosize(none) ndsize(none)  legend(label(2 "0") label(3 "1 to 10" ) label(4 "11 to 20" ) label(5 "21 to 30" ) size(large))

spmap conf_type1 using  "$path\coordprio.dta" , id(id2) fcolor(Reds) clmethod(custom) clbreaks(-1 0 10 20 30) ocolor(none ..)  osize(none)  legtitle("Number of years")  mosize(none) ndsize(none)   legend(label(2 "0") label(3 "1 to 10" ) label(4 "11 to 20" ) label(5 "21 to 30" ) size(large))

spmap conf_type2 using  "$path\coordprio.dta" , id(id2) fcolor(Reds) clmethod(custom) clbreaks(-1 0 10 20 30) ocolor(none ..)  osize(none)  legtitle("Number of years")  mosize(none) ndsize(none)   legend(label(2 "0") label(3 "1 to 10" ) label(4 "11 to 20" ) label(5 "21 to 30" ) size(large))

spmap conf_type3 using  "$path\coordprio.dta" , id(id2) fcolor(Reds) clmethod(custom) clbreaks(-1 0 10 20 30) ocolor(none ..)  osize(none)  legtitle("Number of years")  mosize(none) ndsize(none)   legend(label(2 "0") label(3 "1 to 10" ) label(4 "11 to 20" ) label(5 "21 to 30" ) size(large))
restore

* Figure S6
 hist near_dist,kdensity plotregion(fcolor(white)) graphregion(fcolor(white)) 
 
* Figure S7a
preserve
sum tradew
replace tradew=tradew/r(sd)
foreach v in tradew gdp ucdptot pop polity2{
    sum `v'
replace `v'=`v'-r(mean)
}
collapse (mean) tradew ucdptot pop polity2, by(year)
label   var tradew "Trade openness"
label var ucdptot "Conflicts"
label   var pop "Population"
label   var polity "Democracy index"
twoway (line tradew year)(line ucdptot year, lpattern(dash))(line pop year, lpattern(shortdash))(line polity2 year,lpattern(longdash)) ///
, graphregion(color(white)) ytitle(standardized) note("Trade openness is the world trade (exports plus imports) as share of world GDP." "Conflict is the total number of conflict (UCDP)." "Population is the world population (World Bank)." "Democracy index is the average polity index (PolityIV).")
restore

* Figure S7b 
 corr  tradew ucdptot pop polity2

* Figure S8
preserve
collapse (sum) conflict conf_* best (first) near_dist* id2 , by(gid)
graph drop _all
spmap near_dist using   "$path\coordprio.dta"  , ///
id(id2) fcolor(Blues) clmethod(custom) clbreaks(-5  -2.359637  -1.604164  -.8368567   0) ocolor(none ..) /// 
 osize(none)  legtitle("Proximity:")    mosize(none) ndsize(none)   legend(label(2 "1st quartile") ///
 label(3 "1st quartile to median" ) label(4 "Median to 3rd quartile" ) label(5 "Above 3rd quartile" ) ///
 size(normal) ) name(g2) point(data( "$path\conflict_lowtrade.dta") legenda(on) /// 
 legshow(30) leglabel("Number of conflict") x(xcoord) y(ycoord) size(tiny) fcolor(none) prange(0.1 0.5) prop(conflict) ocolor(maroon%20) ) ///
 title(A. Years with trade openness below median)
 
spmap near_dist using   "$path\coordprio.dta"  , ///
id(id2) fcolor(Blues) clmethod(custom) clbreaks(-5  -2.359637  -1.604164  -.8368567   0) ocolor(none ..) /// 
 osize(none)  legtitle("Proximity:")    mosize(none) ndsize(none)   legend(label(2 "1st quartile") ///
 label(3 "1st quartile to median" ) label(4 "Median to 3rd quartile" ) label(5 "Above 3rd quartile" ) ///
 size(normal) ) name(g1) point(data( "$path\conflict_hightrade.dta") legenda(on) /// 
 legshow(30) leglabel("Number of conflict") x(xcoord) y(ycoord) size(tiny) fcolor(none) prange(0.1 0.5) prop(conflict) ocolor(maroon%20) ) ///
 title(A. Years with trade openness above median)

graph combine g1 g2, graphregion(color(white))  row(2)
restore

* Table S3
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist trade_lin  if year>=1989 , absorb(year xcoord) cluster(gid)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_y Year FE") 

* Table S4
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' trade_lin  if year>=1989 , absorb(year xcoord gid) cluster(gid)
eststo
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_gid "Yes"
estadd local FE_y "Yes"
}
esttab,   cells(b(star fmt(4)) se(par fmt(4)))  mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") ///
 star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_gid Cell FE" "FE_y Year FE") 

* Table S5
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist tradew  trade_lin   year,  absorb(xcoord gadm0_id) cluster(gid)
quietly sum `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") ///
 star(* 0.10 ** 0.05 *** 0.01) drop(_cons year) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE" "FE_y Year FE") 

* Table S6
est clear
qui: reghdfe conflict near_dist trade_lin   ,  absorb(xcoord year gadm0_id) cluster(gid)
quietly sum      conflict  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe conflict near_dist trade_lin  ucdptot_lin    ,  absorb(xcoord year gadm0_id) cluster(gid)
quietly sum      conflict  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe conflict near_dist trade_lin  pop_lin    , absorb(xcoord year gadm0_id)   cluster(gid)
quietly sum      conflict  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe conflict near_dist trade_lin   polity_lin  , absorb(xcoord year gadm0_id)  cluster(gid)
quietly sum      conflict  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe conflict near_dist trade_lin  ucdptot_lin pop_lin polity_lin, absorb(xcoord year gadm0_id)  cluster(gid)
quietly sum      conflict  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("conflict" "conflict" "conflict" "conflict" "conflict") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE" "FE_y Year FE") 

* Table S7
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist_p015  trade_lin_p015 if year>=1989 , absorb(year xcoord gadm0_id ) cluster(gid)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE" "FE_y Year FE")

* Table S8
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist_p005  trade_lin_p005 if year>=1989 , absorb(year xcoord gadm0_id ) cluster(gid)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE" "FE_y Year FE")

* Table S9
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist_before  trade_lin_before   if year>=1989 , absorb(year xcoord gadm0_id ) cluster(gid)
quietly sum `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap   ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE" "FE_y Year FE") 

* Table S10
est clear
qui: reghdfe conflict near_dist_t2 near_dist_t3 if year>=1989 , absorb(year xcoord ) cluster(gid)
quietly sum      conflict  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe conflict near_dist_q2 near_dist_q3 near_dist_q4 if year>=1989, absorb(year xcoord )  cluster(gid)
quietly sum     conflict  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe  conflict close2       if year>=1989, absorb(year xcoord )  cluster(gid)
quietly sum     conflict  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe  conf_type1 close2       if year>=1989, absorb(year xcoord )  cluster(gid)
quietly sum   conf_type1  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe  conf_type2 close2       if year>=1989, absorb(year xcoord )  cluster(gid)
quietly sum  conf_type2  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe  conf_type3 close2       if year>=1989, absorb(year xcoord )  cluster(gid)
quietly sum conf_type3 if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
qui: reghdfe  lnbest close2       if year>=1989, absorb(year xcoord )  cluster(gid)
quietly sum    lnbest  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
esttab , drop(_cons)  cells(b(star fmt(4)) se(par fmt(4))) ///
mtitles("conflict" "conflict" "conflict" "conflict" "conflict" "state-based" "non-state" "one-sided" "ln(Num. deaths)") ///
star(* 0.10 ** 0.05 *** 0.01) ar2 label  nogaps compress wrap     scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_y Year FE")  nogaps

* Table S11
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' close2  close2_trade if year>=1989 , absorb(year xcoord gadm0_id) cluster(gid)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE" "FE_y Year FE")

* Table S12
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist  trade_lin near_dist_coast trade_lin_coast  if year>=1989 , absorb(year xcoord gadm0_id ) cluster(gid)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE" "FE_y Year FE")

* Table S13
est clear 
foreach v in gdelt_bin gdelt_assault_bin gdelt_fight_bin gdelt_conv_bin gdelt_salw_bin{ 
qui: reghdfe `v' near_dist      if year>=1989, absorb(year xcoord )  cluster(gid)
quietly sum  `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "assault" "fight" "conventional" "small arms") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_y Year FE") 

* Table S14
est clear 
foreach v in gdelt_bin gdelt_assault_bin gdelt_fight_bin gdelt_conv_bin gdelt_salw_bin{ 
qui: reghdfe `v' near_dist trade_lin if year>=1989 , absorb(year xcoord gadm0_id) cluster(gid)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "assault" "fight" "conventional" "small arms") ///
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE" "FE_y Year FE") 

* Table S15
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist trade_lin  if year>=1989 , absorb(year xcoord gadm0_id) cluster(gadm0_id)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") /// 
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE"  "FE_y Year FE") 

* Table S16
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist trade_lin  if year>=1989 , absorb(year xcoord gadm0_id) cluster(gadm1_id)
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
eststo
}
esttab,   cells(b(star fmt(4)) se(par fmt(4))) mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") /// 
star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE"  "FE_y Year FE")

* Table S17
acreg conflict near_dist  trade_lin , correctr2 pfe1(year) pfe2(id) id(gid) time(year) spatial latitude(xcoord) longitude(ycoord) dist(1000) lag(50)
estimates store r1
acreg conf_type1 near_dist  trade_lin , correctr2 pfe1(year) pfe2(id) id(gid) time(year) spatial latitude(xcoord) longitude(ycoord) dist(1000) lag(50)
estimates store r2
acreg conf_type2 near_dist  trade_lin , correctr2 pfe1(year) pfe2(id) id(gid) time(year) spatial latitude(xcoord) longitude(ycoord) dist(1000) lag(50)
estimates store r3
acreg conf_type3 near_dist  trade_lin , correctr2 pfe1(year) pfe2(id) id(gid) time(year) spatial latitude(xcoord) longitude(ycoord) dist(1000) lag(50)
estimates store r4
acreg lnbest near_dist  trade_lin , correctr2 pfe1(year) pfe2(id) id(gid) time(year) spatial latitude(xcoord) longitude(ycoord) dist(1000) lag(50)
estimates store r5
esttab r1 r2 r3 r4 r5 ,  cells(b(star fmt(4)) se(par fmt(4))) mtitles("Conflict" "state-based" "non-state" "one-sided" "ln(Num. deaths)") star(* 0.10 ** 0.05 *** 0.01) ar2 label  nogaps compress wrap     scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_y Year FE")  nogaps

* Table S18
est clear 
foreach v in conflict conf_type1 conf_type2 conf_type3 lnbest{ 
qui: reghdfe `v' near_dist prox_dca_f  trade_lin if year>=1989 , absorb(year xcoord gadm0_id ) cluster(gid)
eststo
quietly sum      `v'  if e(sample)==1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local FE_lat "Yes"
estadd local FE_ctry "Yes"
estadd local FE_y "Yes"
}
esttab,   cells(b(star fmt(4)) se(par fmt(4)))  mtitles("any event" "state-based" "non-state" "one-sided" "ln(deaths+1)") star(* 0.10 ** 0.05 *** 0.01) drop(_cons) ar2 label  nogaps compress  wrap     ///
scalars("y_mean_round Mean dep. var." "FE_lat Latitude FE" "FE_ctry Country FE" "FE_y Year FE") 